import request from "@/axios/request";
import url from "@/axios/url";
const { mesUrl, adminUrl } = url();
// 导出url
export const exportUrl = `${mesUrl}wmsOutTask/export`;
// 获取详情
export function getInfo(id = "") {
  return request({
    url: `${mesUrl}wmsOutTask/info/${id}`,
    method: "get",
  });
}

// 根据单号获取展示详情
export function getInfoByOrderNo(id = "", flag = true) {
  return request({
    url: `${mesUrl}wmsOutTask/info/${id}/${flag}`,
    method: "get",
  });
}

//分页查询
export function getList(params = {}) {
  return request({
    url: `${mesUrl}mesKtOutTask`,
    method: "get",
    params,
  });
}
export function getListSpecial(params = {}) {
  return request({
    url: `${mesUrl}mesKtOutTask/special`,
    method: "get",
    params,
  });
}
// 子列表
export function subList(orderNo) {
  return request({
    url: `${mesUrl}wmsOutTask/sub/${orderNo}`,
    method: 'get',
  });
}
//新增
export function rowCreate(data = {}) {
  return request({
    url: `${mesUrl}wmsOutTask`,
    method: "post",
    data,
  });
}
//批量新增
export function rowBatchCreate(data = {}) {
  return request({
    url: `${mesUrl}wmsOutTask/batch`,
    method: "post",
    data,
  });
}

//过账
export function rowAccount(data = {}) {
  return request({
    url: `${mesUrl}wmsOutTaskPda/confirm`,
    method: "post",
    data,
  });
}

/**
 * 特殊出库
 * @param data
 * @returns {*|Promise<*>}
 */
export function outStockSpecial (data = {}) {
  return request({
    url: `${mesUrl}mesKtOutTask/outStockSpecial`,
    method: 'post',
    data,
  });
}

//波次制单
export function waveCreate(ids) {
  return request({
    url: `${mesUrl}wmsOutTask/waveCreate/${ids}`,
    method: "get",
  });
}
//波次撤销
export function waveCancel(ids) {
  return request({
    url: `${mesUrl}wmsOutTask/waveCancel/${ids}`,
    method: "get",
  });
}
//修改
export function rowUpdate(data = {}) {
  return request({
    url: `${mesUrl}wmsOutTask`,
    method: "put",
    data,
  });
}
export function rowUpdateForPc(data = {}) {
  return request({
    url: `${mesUrl}wmsOutTask/updateForPc`,
    method: "post",
    data,
  });
}
export function agreeOut(data = {}) {
  return request({
    url: `${mesUrl}mesKtOutTask/agreeOut`,
    method: "post",
    data,
  });
}
//删除
export function rowDel(id) {
  return request({
    url: `${mesUrl}wmsOutTask/${id}`,
    method: "put",
  });
}

//下拉框字典等
// 查询库区编码列表
export function getAreaCodeList(params = {}) {
  return request({
    url: `${adminUrl}baseArea/list`,
    method: "get",
    params,
  });
}
// 查询单据类型 10领料出库20采购退货出库30销售出库40其它出库列表
export function getOrderTypeList() {
  return request({
    url: `${adminUrl}dict/type/wms_out_order_type`,
    method: "get",
  });
}
// 查询订单状态 10创建20出库中30完成列表
export function getOrderStatusList() {
  return request({
    url: `${adminUrl}dict/type/wms_out_order_status`,
    method: "get",
  });
}
// OQC生成状态 0：未生成 1：已生成（wms_quality_generete_status）
export function getQualityGenereteStatusList() {
  return request({
    url: `${adminUrl}dict/type/wms_quality_generete_status`,
    method: "get",
  });
}
// OQC 检验物料状态 0：免检 1：质检（ quality_type）
export function getQualityMaterialStatus() {
  return request({
    url: `${adminUrl}dict/type/quality_type`,
    method: "get",
  });
}
// OQC检验状态：0-未开始、1-进行中、2-完成、3-已关闭（qms_inspection_result_status）
export function getQualityStatus() {
  return request({
    url: `${adminUrl}dict/type/qms_inspection_result_status`,
    method: "get",
  });
}
// OQC检验结果：0-未检验、1-合格、2-不合格、3-特采、4-拣选（inspection_assignment_result）
export function getQualityResultList() {
  return request({
    url: `${adminUrl}dict/type/inspection_assignment_result`,
    method: "get",
  });
}
// 查询ERP过账状态 00未处理 10保存成功 11保存失败 20提交成功 21提交失败 30审核成功 31审核失败 40下推成功 41下推失败
export function getErpStatusList() {
  return request({
    url: `${adminUrl}dict/type/wms_erp_status`,
    method: "get",
  });
}
// 查询库存物料编码列表
export function getAllGoods(params = {}) {
  return request({
    url: `${mesUrl}wmsInventorySn/getAllGoods`,
    method: "get",
    params,
  });
}

// 获取仓库信息
export function getCurrentWarehouseCode() {
  return request({
    url: `${adminUrl}basic`,
    method: "get",
  });
}

export function getLineCode(params = {}) {
  return request({
    url: `${adminUrl}baseFactoryModeling/children`,
    method: "get",
    params,
  });
}

export function getCustomerCode() {
  return request({
    url: `${adminUrl}dict/type/wms_customer_code`,
    method: "get",
  });
}

//查询客户列表
export function getCustomerList(params = {}) {
  return request({
    url: `${adminUrl}commonCustomer`,
    method: 'get',
    params
  })
}

//下拉框字典等
// 查询客商类别编码列表
export function getCustomerTypeValueList() {
  return request({
    url: `${adminUrl}dict/type/customer_type`,
    method: 'get'
  })
}

// 查询物料类型 数据字典：成品、半成品、原材料列表
export function getGoodsTypeKeyList() {
  return request({
    url: `${adminUrl}dict/type/material_type`,
    method: 'get',
  });
}

// 查询库位列表
export function getLocationCodeList(params = {}) {
  return request({
    url: `${adminUrl}baseLocation/list`,
    method: "get",
    params,
  });
}

//查询待出库物料列表
export function getGoodsList(params = {}) {
  return request({
    url: `${mesUrl}wmsInventorySn/getGoodsList/out`,
    method: "get",
    params,
  });
}


//查询待出库物料列表
export function getGoodsListFromPlatform(params = {}) {
  return request({
    url: `${mesUrl}wmsOutTask/getGoodsList`,
    method: "get",
    params,
  });
}


// 查询生产订单状态下拉框
export function getPrdOrderStatusList () {
  return request({
    url: `${adminUrl}dict/type/plan_status`,
    method: "get",
  });
}
// 查询生产订单信息列表
export function getPrdOrderList (params = {}) {
  return request({
    url: `${mesUrl}wmsOutTask/pagePrdOrderPlan`,
    method: "get",
    params,
  });
}
//分页查询--弹窗
export function getDetailList(params = {}) {
  return request({
    url: `${mesUrl}wmsInventorySn`,
    method: "get",
    params
  })
}


